import urllib2

base = ""
password = ""

def menu():
    print ""
    print "1. Login"
    print "2. Download config.bin"
    print "3. Restart"
    print "4. Reset"
    print "5. Logout"
    print ""
    print "6. Exit"
    print ""
    goto = int(raw_input("> "))

    if (goto == 1): login()
    elif (goto == 2): download()
    elif (goto == 3): restart()
    elif (goto == 4): reset()
    elif (goto == 5): logout()
    elif (goto == 6): done()

def login():
    base = "http://" + str(raw_input("IP> "))
    password = str(raw_input("Password> "))

    try:
        urllib2.urlopen(base + "/cgi-bin/login.exe?pws=" + password)
        return
    
    except:
        print "Login Failed =["
        return

def download():
    print "download func"
    return

def restart():
    print "restart func"
    return

def reset():
    print "reset func"
    return

def logout():
    print "logout func"
    return

def done():
    print "done func"
    return

space = "                       "
print space + "--==++[ Router Config v1.1 ]++==--" + space

while True:
    main()
